/*    */ package server.console.groups.setting;
/*    */ import com.alee.extended.panel.GroupPanel;
import com.alee.extended.panel.GroupingType;
import com.alee.laf.button.WebButton;
import com.alee.laf.list.WebList;
import com.alee.laf.list.editor.ListEditAdapter;
import com.alee.laf.list.editor.ListEditListener;
import com.alee.laf.scroll.WebScrollPane;

import javax.swing.*;
import java.awt.*;

/*    */
/*    */
/*    */
/*    */
/*    */
/*    */
/*    */
/*    */
/*    */
/*    */ 
/*    */ public class BannedConfigGroup extends AbstractConfigGroup {
/*    */   BannedConfigGroup(ConfigPanel owner) {
/* 15 */     super(owner, "禁言系统");
/*    */   }
/*    */   
/*    */   private static DefaultListModel<String> createData() {
/* 19 */     DefaultListModel<String> model = new DefaultListModel<>();
/* 20 */     model.addElement("外挂");
/* 21 */     model.addElement("傻逼");
/* 22 */     return model;
/*    */   }
/*    */ 
/*    */   
/*    */   public Component getPreview() {
/* 27 */     AbstractConfigGroup.TitleWebPanel titleWebPanel1 = new AbstractConfigGroup.TitleWebPanel("禁言设置");
/*    */     
/* 29 */     titleWebPanel1.add((Component)(new GroupPanel(false, new Component[] { (Component)new AbstractConfigGroup.ConfigComponent("禁言时间(分钟)")
/*    */           
/* 31 */           })).setMargin(5));
/*    */     
/* 33 */     AbstractConfigGroup.TitleWebPanel titleWebPanel2 = new AbstractConfigGroup.TitleWebPanel("管理敏感单词 (双击一项可直接编辑)");
/*    */ 
/*    */     
/* 36 */     final WebList list = new WebList(createData());
/* 37 */     list.setEditable(true);
/* 38 */     list.setMultiplySelectionAllowed(true);
/* 39 */     list.addListEditListener((ListEditListener)new ListEditAdapter()
/*    */         {
/*    */           public void editFinished(int index, Object oldValue, Object newValue) {
/* 42 */             if (((String)newValue).isEmpty()) {
/* 43 */               ((DefaultListModel)list.getModel()).removeElementAt(index);
/*    */             }
/*    */           }
/*    */         });
/*    */     
/* 48 */     WebButton addButton = new WebButton("增加", e -> {
/*    */           if (list.getModel() instanceof DefaultListModel) {
/*    */             DefaultListModel<String> model = (DefaultListModel<String>)list.getModel();
/*    */             
/*    */             model.addElement(" ");
/*    */             
/*    */             list.editCell(model.getSize() - 1);
/*    */           } 
/*    */         });
/* 57 */     WebButton removeButton = new WebButton("删除", e -> {
/*    */           if (list.getSelectedIndex() == -1) {
/*    */             return;
/*    */           }
/*    */           int[] indexs = list.getSelectedIndices();
/*    */           int delete = 0;
/*    */           for (int i : indexs) {
/*    */             ((DefaultListModel)list.getModel()).removeElementAt(i - delete);
/*    */             delete++;
/*    */           } 
/*    */           list.setSelectedIndex(list.getModelSize() - 1);
/*    */         });
/* 69 */     removeButton.setEnabled(false);
/*    */ 
/*    */     
/* 72 */     WebButton editButton = new WebButton("编辑", e -> list.editSelectedCell());
/* 73 */     editButton.setEnabled(false);
/*    */     
/* 75 */     list.addListSelectionListener(e -> {
/*    */           removeButton.setEnabled(true);
/*    */           
/*    */           editButton.setEnabled(true);
/*    */         });
/* 80 */     titleWebPanel2.add((Component)(new GroupPanel(GroupingType.fillFirst, new Component[] { (Component)new WebScrollPane((Component)list), (Component)new GroupPanel(false, new Component[] { (Component)addButton, (Component)removeButton, (Component)editButton
/*    */               
/*    */               })
/* 83 */           })).setMargin(10, 30, 0, 50));
/* 84 */     return (Component)new GroupPanel(GroupingType.fillLast, false, new Component[] { (Component)titleWebPanel1, (Component)titleWebPanel2 });
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\server\console\groups\setting\BannedConfigGroup.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */